
import requests
import json
import random
import string
import secrets
def generate_random_string(length):
    """生成指定长度的随机字符串"""
    letters_and_digits = string.ascii_letters + string.digits
    return ''.join(random.choice(letters_and_digits) for _ in range(length))

# API URL
url = "http://192.168.0.148:28311/interface/settle/settleBatch"

# Request headers
headers = {
    'Content-Type': 'application/json',
}

# Request body
data = {
    "appid": "1104332740187316224",
    "data": {
        "acctNo": "30206466859031",
        "businessId": "1232637442448941056",
        "freelancers": [
            {
                "acctNo": "6226305269471352",
                "idno": "210102198703022307",
                "name": "晏峻浩",
                "outSeqNo": "dD1ASfSFDFDfC56CdF",
                "remark": "FDFSD",
                "settleFee": "5001000"
            }
        ],
        "outBatchNo": "5A65615FD661DDS704",
        "payStartTime": "2022-03-02 17:16:31",
        "taskId": "1232640950911770624",
        "notityUrl": "http://xlg.zx2289.cn:8880/interfacecallback/send",
        "total": 1,
        "totalSettleFee": "100100"
    },
    "nonceStr": "1dFSS6FdSDsASfDd11",
    "reqMsgId": "{fSSD5DFsFF1C5S704",
    "sign": "111",
    "signType": "RSA",
    "timestamp": "1645770163620"
}

# Convert the data to JSON format
json_data = json.dumps(data)
s = data["data"]
s["reqMsgId"] = generate_random_string(15)
s["outBatchNo"] = generate_random_string(15)

json_data1 = json.dumps(s)
print(s)
print(s["reqMsgId"],s["outBatchNo"])

# Make the POST request
response = requests.post(url, headers=headers, data=json_data1)

# Print the response status code and content
print("Response Status Code:", response.status_code)
print("Response Content:", response.text)



